package com.atguigu.oss.controller;

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.OssService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/eduoss/fileoss")

public class OssController {
    @Autowired
    private OssService ossService;

    @ApiOperation("上传图像")
    @CrossOrigin
    @PostMapping(value = ("/file"))
    public R uploadOssFile(MultipartFile file) {
        //获取上传文件，MultipartFile
        //返回上传oss的url
        String url = ossService.upload(file);
        return R.ok().data("url", url);

    }

    @CrossOrigin
    @GetMapping(value = ("/test"))
    public R test() {


        return R.ok().data("ms", "访问成功了");
    }


}
